﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Login</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" /><link href="../demo.css" rel="stylesheet" type="text/css" />

    <style type="text/css">
    body
    {
        width:100%;height:100%;margin:0;overflow:hidden;
    }
    </style>
    <script src="../scripts/boot.js" type="text/javascript"></script>
    
</head>
<body >   
<div id="loginWindow" class="mini-window" title="用户登录" style="width:350px;height:200px;" 
   showModal="true" showCloseButton="false"
    >

    <div id="loginForm" style="padding:15px;padding-top:10px;">
        <table >
            <tr>
                <td style="width:60px;"><label for="username$text">帐号：</label></td>
                <td>
                    <input id="username" name="username" class="mini-textbox" required="true" requiredErrorText="账号不能为空" style="width:150px;"/>
                </td>    
            </tr>
            <tr>
                <td style="width:60px;"><label for="password$text">密码：</label></td>
                <td>
                    <input id="password" name="password" class="mini-password" requiredErrorText="密码不能为空" required="true" style="width:150px;" onenter="onLoginClick"/>
                </td>
            </tr>    
            <tr>
                <td style="width:60px;"><label for="validate$text">验证码：</label></td>
                <td>
                    <input id="validate" name="validate" class="mini-textbox" requiredErrorText="验证码不能为空" required="true" style="width:150px;" onenter="onLoginClick"/>
                    <td><img id="validateCode" title="点击刷新验证码"  src="../validate_code"  onclick="validate_refrash()"/></td></td>
                </td>
            </tr>            
            <tr>
                <td></td>
                <td style="padding-top:5px;">
                    <a onclick="onLoginClick" class="mini-button" style="width:60px;">登录</a>
                    <a onclick="onResetClick" class="mini-button" style="width:60px;">重置</a>
                </td>
            </tr>
        </table>
    </div>

</div>


    

    
    <script type="text/javascript">
        mini.parse();

        var loginWindow = mini.get("loginWindow");
        loginWindow.show();

        function onLoginClick(e) {
            var form = new mini.Form("#loginWindow");

            var o = form.getData();            

            form.validate();
            if (form.isValid() == false) return;

            var json = mini.encode(o);
            $.ajax({
                url: "../admin/admin_login",
				type: 'post',
				dataType: 'json',
                data: o,
                cache: false,
                success: function (obj) {
                	if(obj.result == "success"){
                		loginWindow.hide();
			            mini.loading("登录成功，马上转到系统...", "登录成功");
			            setTimeout(function () {
			                window.location = "../admin/admin_index";
			            }, 1500);
                    }
                    else{
                    	mini.alert(obj.data);
                    	validate_refrash()
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    mini.alert(jqXHR.data);
                }
            });

            
        }
        
			function validate_refrash(){
				$("#validateCode").attr("src", "../validate_code?" + Math.floor(Math.random()*100))
			}
        function onResetClick(e) {
            var form = new mini.Form("#loginWindow");
            form.clear();
        }
    </script>

</body>
</html>